<?php
!empty($_REQUEST['action']) ? $action = $_REQUEST['action'] : exit(json_encode(['code'=>202, "msg"=>"请输入网址"],JSON_UNESCAPED_UNICODE));
include_once 'lib/data.php';
$gid = uniqid();
$data = Service($pay_config['appid'],$pay_config['private_key'],$_POST['money'],$_POST['des'],$gid);
if($action == 'pay'){ if(!empty($data['code'] && $data['code']=='10000')):
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?php echo $pay_config['title'];?> - 支付结果</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="keywords" content="<?php echo $pay_config['keywords'];?>">
<meta name="description" content="<?php echo $pay_config['describe'];?>">
<link rel="shortcut icon" href="http://q1.qlogo.cn/g?b=qq&nk=<?php echo $pay_config['qq'];?>&s=100">
<link rel="stylesheet" type="text/css" href="<?php echo $domain;?>public/style.css" />
<script src="<?php echo $domain;?>public/jquery.min.js"></script>
</head>
<body>
<div class="web">
	<div class="container">
		<!--支付-->
		<div class="Payment">
		    <div class="Payment_default">
		        <p class="pay_logo"><img src="" alt="" style="height:30px;"></p>
			    <p>商品名称：<?php echo $_REQUEST['des'];?></p>
				<p class="pay_money">￥<?php echo $_REQUEST['money'];?></p>
				<p class="pay_qrcode"><img src="https://api.pwmqr.com/qrcode/create/?url=<?php echo $data['qr_code'];?>" alt=""></p>
				<div class="pay_info">
				    <p>商户订单号：<?php echo $gid;?></p>
					<p>请使用支付宝扫一扫</p>
					<?php if(stristr($_SERVER['HTTP_USER_AGENT'],'Android')||stristr($_SERVER['HTTP_USER_AGENT'],'iPhone')||stristr($_SERVER['HTTP_USER_AGENT'],'iPad')){?>
					<p class="wapds"><a href="alipayqr://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=<?php echo urlencode($data['qr_code']);?>">点击打开支付宝打赏</a></p>
					<?php }?>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
setInterval(function() {
	var url = "lib/data.php?action=serve";
	$.ajax({
		type: "POST",
        url: url,
        data: {gid:"<?php echo $gid;?>"},
        dataType: "JSON",
        success: function(result){
			if (result.code == 200){
				alert("感谢大爷打赏");
				window.location.href="./";
			}
		}
	});
}, 5000);
setInterval(function(){window.location.reload();}, 60000);
</script>
</body>
</html>
<?php endif;}?>